home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 1 / Macwelt DVD 1.toast / Web-Publishing / HTML-Editoren / Alpha ƒ / Help / MacPerl Specifics < prev    next >
Encoding:
Text File  |  2000-08-23  |  8.7 KB  |  258 lines

  1.  
  2. Specific features of MacPerl
  3.  
  4.                                                version: 5.0
  5.                                                created: 09/05/94 {06:36:17 am}
  6.                                            last update: 08/23/00 {10:35:23 am}
  7.  
  8. Author: Matthias Neeracher
  9.  
  10. This file describes differences between MacPerl and a typical Unix perl
  11. implementation.  Much of this information can also be found at the end of
  12. PerlHelp.  If you have 411, search for Perl…Macintosh…Extensions.
  13.  
  14.  
  15.           1. VARIA
  16.  
  17.  
  18. "\n" on a Mac means ASCII 13, as opposed to Unix, where it means ASCII 10
  19.  
  20. Pathnames are specified as:
  21.  
  22.     volume:folder:file              for absolute pathnames
  23.     :folder:file                    for relative pathnames
  24.     :file                           for relative pathnames
  25.     file                            for relative pathnames
  26.  
  27. MacPerl has a limited capability to handle constructs like `command` or
  28. open(F, "|command"), if you are the lucky owner of ToolServer. 
  29. Additionally, whether you have toolserver or not, `pwd` and `Directory`
  30. (case is significant) always return the current directory, followed by a
  31. newline.
  32.  
  33.  
  34.           2. SOCKETS
  35.  
  36.  
  37. MacPerl has more Socket families than Unix Perl.  Additionally, there is a
  38. call choose() to allow the user to interactively specify addresses or file
  39. names.  As there are lots of rather complicated data types, there is a
  40. library header "GUSI.ph" which defines packing/unpacking procedures.
  41.  
  42. Choose() is called as follows:
  43.  
  44.     &MacPerl'Choose(DOMAIN,TYPE,PROMPT,CONSTRAINT,FLAGS,DEFAULT)
  45.     &MacPerl'Choose(DOMAIN,TYPE,PROMPT,CONSTRAINT,FLAGS)
  46.     &MacPerl'Choose(DOMAIN,TYPE,PROMPT,CONSTRAINT)
  47.     &MacPerl'Choose(DOMAIN,TYPE,PROMPT)
  48.  
  49. Puts up a modal dialog prompting the user to choose an address.  DOMAIN
  50. specifies the communication domain, like for socket().  TYPE may be used by
  51. future communication domains to further differentiate within a domain, but
  52. is ignored by current domains.  PROMPT is a message that will appear in the
  53. dialog.  CONSTRAINT may be set to a suitable packed value to restrict the
  54. types of acceptable addresses.
  55.  
  56. Examples:
  57.  
  58.       require "GUSI.ph";
  59.  
  60.       $file = 
  61.          MacPerl'Choose(
  62.             &GUSI'AF_FILE, 0, "", 
  63.             &GUSI'pack_sa_constr_file("OBJ ", "TEXT"));
  64.                         
  65.                     Return the full pathname of an existing text
  66.                     or MPW object file.
  67.      
  68.       $dir = &MacPerl'Choose(&GUSI'AF_FILE, 0, "", "", &GUSI'CHOOSE_DIR);
  69.  
  70.                     Return the full pathname of an existing directory.
  71.                         
  72.       $file = 
  73.          &MacPerl'Choose(
  74.             &GUSI'AF_FILE, 0, "", "", 
  75.             &GUSI'CHOOSE_NEW + &GUSI'CHOOSE_DEFAULT, "yo");
  76.  
  77.                     Return the pathname of a new file to be created.
  78.                                      
  79. Socket families are:
  80.  
  81. Internet:
  82.  
  83. Packing addresses:      &GUSI'pack_sockaddr_in(family, address, port)
  84. Unpacking addresses:    (family, address, port) = &GUSI'unpack_sockaddr_in(addr)
  85. Choose:                 Not available.
  86.  
  87. Unix:
  88.  
  89. Packing addresses:      &GUSI'pack_sockaddr_un(family, path)
  90. Unpacking addresses:    (family, path) = &GUSI'unpack_sockaddr_un(addr)
  91. Choose:                 choose(&GUSI'AF_UNIX, 0, "", "", 0, "");
  92.                         looks up an existing address.
  93.                         choose(
  94.                             &GUSI'AF_UNIX, 0, "Yes ?", "", 
  95.                             &GUSI'CHOOSE_NEW + &GUSI'CHOOSE_DEFAULT, "yo");
  96.                         creates a new address.
  97.                         No constraints may be specified.
  98.  
  99. Appletalk (ADSP):
  100.  
  101. Packing addresses:      &GUSI'pack_sockaddr_atlk(family, net, node, socket)     (numerical)
  102.                             &GUSI'pack_sockaddr_atlk_sym(family, obj, type, zone)   (symbolic)
  103. Unpacking addresses:    (family, net, node, socket) = &GUSI'unpack_sockaddr_atlk(addr)
  104.                             (family, obj, type, zone) = &GUSI'unpack_sockaddr_atlk_sym(addr)
  105. Choose:                 choose(&GUSI'AF_APPLETALK, 0, "Eh ?", 
  106.                                 &GUSI'pack_sa_constr_atlk("LaserWriter", "GorillaWriter"),
  107.                                 0, "");
  108.                         looks up an existing address.
  109.                         New addresses may not currently be created with choose.
  110.  
  111. PPC Toolbox:
  112.  
  113. Packing addresses:      &GUSI'pack_sockaddr_ppc(family, type, name, porttype)
  114. Unpacking addresses:    Not available.
  115. Choose:                 choose(&GUSI'AF_PPC, 0, "Eh ?", 
  116.                                 &GUSI'pack_sa_constr_ppc("Gonkulator"), 0, "");
  117.                         looks up an existing address.
  118.                         New addresses may not currently be created with choose.
  119.  
  120.  
  121.           3. ADDITIONAL FUNCTIONS AVAILABLE IN MACPERL
  122.  
  123.  
  124.     &MacPerl'Answer(PROMPT)
  125.     &MacPerl'Answer(PROMPT,BUTTON1)
  126.     &MacPerl'Answer(PROMPT,BUTTON1,BUTTON2)
  127.     &MacPerl'Answer(PROMPT,BUTTON1,BUTTON2,BUTTON3)
  128.  
  129. Presents to the user a dialog with 1, 2, or 3 buttons. 
  130.           
  131. Examples:
  132.           
  133.       &MacPerl'Answer("Nunc et in hora mortis nostrae", "Amen");
  134.                           
  135.                     always returns 0.
  136.                         
  137.       &MacPerl'Answer("I refuse");
  138.       
  139.                     is equivalent to &MacPerl'Answer("I refuse", "OK");
  140.       
  141.       &MacPerl'Answer("Delete hard disk ?", "OK", "Cancel");
  142.               
  143.                     returns 1 for OK, 0 for Cancel
  144.  
  145.       &MacPerl'Answer("Overwrite existig file", "Overwrite", "Skip", "Cancel");
  146.           
  147.                     returns 2 for Overwrite, 1 for Skip, 0 for Cancel
  148.                             
  149.     &MacPerl'Ask(PROMPT, DEFAULT)
  150.     &MacPerl'Ask(PROMPT)
  151.  
  152. Asks the user for a string.  A default value may be given.  Returns undef
  153. if the dialog is cancelled.
  154.           
  155. Example:
  156.           
  157.       $phone = &&MacPerl'Ask("Enter your phone number:");
  158.       $name = &&MacPerl'Ask("Enter your first name", "Bruce");
  159.           
  160.                     Useful for Australian database applications
  161.                             
  162.     &MacPerl'Pick(PROMPT, VALUES)
  163.  
  164. Asks the user to pick a choice from a list.  VALUES is a list of choices. 
  165. Returns undef if the dialog is cancelled.
  166.           
  167. Examples:
  168.           
  169.       $color = &MacPerl'Pick("What's your favorite color baby ?", "Red", "Green", "Gold");
  170.           
  171.     &MacPerl'SetFileInfo(CREATOR,TYPE,FILE...)
  172.  
  173. Changes the file types and creators of the file(s).
  174.  
  175. Examples:
  176.  
  177.      &MacPerl'SetFileInfo("MPS ", "TEXT", yin, yang);
  178.  
  179.                     Turn yin and yang into MPW text files
  180.  
  181.     &MacPerl'GetFileInfo(FILE)
  182.  
  183. In scalar context, returns the file type.  In array context, returns
  184. (creator,type).
  185.  
  186. Examples:
  187.  
  188.      &MacPerl'GetFileInfo(yin);
  189.  
  190.                     Returns "TEXT" or ("MPS ", "TEXT").
  191.  
  192.     &MacPerl'DoAppleScript(SCRIPT)
  193.  
  194. Execute an AppleScript script.
  195.          
  196. Example:
  197.          
  198.      &MacPerl'DoAppleScript(<<END_SCRIPT);
  199.      tell application "MacPerl"
  200.      make new Window
  201.      copy "Inserting text the hard way." to character 1 of front Window
  202.      end tell
  203.      END_SCRIPT
  204.  
  205.     &MacPerl'Reply(ANSWER)
  206.  
  207. Reply to current DoScript request.  Useful if you are calling Perl scripts
  208. from other applications.
  209.          
  210.     &MacPerl'Quit(LEVEL)
  211.  
  212. If Level is 0, don't quit after ending the script.  If 1, quit if running
  213. under a runtime version, if 2, always quit.
  214.  
  215.     &MacPerl'LoadExternals(LIBFILE)
  216.  
  217. Load XCMD and XFCN extensions contained in file LIBFILE, which is searched
  218. along the same path as it would be for a require.  The extensions are made
  219. accessible in the current package, unless they conatin an explicit package
  220. name.
  221.  
  222.     &MacPerl'DebugExternals(DEBUGLEVEL)
  223.  
  224. If DEBUGLEVEL is 0, don't print any debug information for XCMDs and XFCNs. 
  225. If 1, print information for unimplemented callbacks.  If 2, print
  226. informations for all callbacks.
  227.  
  228.     &MacPerl'FAccess(FILE, CMD, ARGS)
  229.  
  230. When called from the tool, manipulate various information of files.  To get
  231. the command constants, it's convenient to require "FAccess.ph".
  232.  
  233.     $TAB = &MacPerl'FAccess(FILE, &F_GTABINFO)
  234.     &MacPerl'FAccess(FILE, &F_STABINFO, TAB)
  235.  
  236. Manipulate tabulator setting (in spaces per tab).
  237.          
  238.     ($FONTNAME, $FONTSIZE) = &MacPerl'FAccess(FILE, &F_GFONTINFO)
  239.     $FONTNUM = &MacPerl'FAccess(FILE, &F_GFONTINFO)
  240.     &MacPerl'FAccess(FILE, &F_SFONTINFO, FONT [, SIZE])
  241.  
  242. Manipulate font and size information.  Both font names and font numbers are
  243. accepted for F_SFONTINFO; F_GFONTINFO returns a font name in an array
  244. context, a font number in a scalar context.
  245.          
  246.     ($STARTSEL, $ENDSEL, $DISPLAYTOP) = &MacPerl'FAccess(FILE, &F_GSELINFO)
  247.     $STARTSEL = &MacPerl'FAccess(FILE, &F_GSELINFO)
  248.     &MacPerl'FAccess(FILE, &F_SSELINFO, $STARTSEL, $ENDSEL [, $DISPLAYTOP])
  249.  
  250. Manipulate the MPW selection of a file.
  251.          
  252.     ($LEFT, $TOP, $RIGHT, $BOTTOM) = &MacPerl'FAccess(FILE, &F_GWININFO)
  253.     $TOP = &MacPerl'FAccess(FILE, &F_GWININFO)
  254.     &MacPerl'FAccess(FILE, &F_SWININFO, LEFT, TOP [, RIGHT, BOTTOM])
  255.  
  256. Manipulate the window position.
  257.  
  258.